package com.woupla.company;

import java.io.Serializable;


import com.ocpsoft.pretty.faces.annotation.URLMapping;
import com.ocpsoft.pretty.faces.annotation.URLAction;

import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.jboss.solder.logging.Logger;

import com.woupla.company.CompanyEJB;
import com.woupla.model.Company;

@Named("company")
@ViewScoped
@URLMapping(id = "view-company", pattern = "/company/#{iid  : company.itemId}", viewId = "/desktop/company.xhtml")
public class ViewCompanyController implements Serializable {
	
	@Inject
	private Logger log;
	
	private static final long serialVersionUID = -8912254295304875243L;
	@Inject
	private CompanyEJB companyEJB;

	private Long itemId;
	
	@Inject
	private Company company;

	@URLAction
	public void init()
	{
		log.info("find company with id " + itemId);
		if ( itemId != null ) {
			this.company = companyEJB.findCompanyById(itemId);
			if(company.getName() == null) {
				
			} else {
				
			}
		} else {
			
		}
	}
	
	public void setItemId(Long itemid)
	{
		this.itemId = itemid;
	}
	
	public Long getItemId()
	{
		return this.itemId;
	}
	
	public Company getCompany()
	{
		return this.company;
	}
}
